package com.douqu.game.battle.entity;

import com.douqu.game.battle.entity.tmp.PlayerBattleTmp;
import com.douqu.game.core.config.common.Position;
import com.douqu.game.core.entity.db.CardDB;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.util.LogUtils;

import java.util.List;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-01-25 11:19
 */
public class WaitToBattlefieldCard {

    private CardDB cardDB;

    private List<Position> positionList;

    private PlayerBattleTmp playerBattleTmp;

    public WaitToBattlefieldCard(PlayerBattleTmp playerBattleTmp, CardDB cardDB, List<Position> positionList)
    {
        this.playerBattleTmp = playerBattleTmp;
        this.cardDB = cardDB;
        this.positionList = positionList;
    }

    public boolean checkToBattlefield()
    {
        if(playerBattleTmp.getCurCrystal() >= cardDB.getConfig().crystal && DataFactory.currentTime >= playerBattleTmp.getNextPutCardTime())
        {
            LogUtils.info("等待列表中的卡满足出卡条件,出卡 ----->" + cardDB.id + "," + cardDB.getConfig().getName());
            playerBattleTmp.soldierBorn(cardDB, positionList);
            if(!playerBattleTmp.getBattleController().getBattleDetailType().isBothPlayer())
            {
                //检测AI
//            LogUtils.debug("对手开始检测AI出牌：" + target);
                playerBattleTmp.getTargetBattleTmp().checkAI(DataFactory.currentTime);
            }

            return true;
        }
        return false;
    }
}
